package DBUnitTests;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

import junit.framework.TestCase;

import org.junit.Test;

import dataBase.ColumnValue;
import dataBase.ISqlTable;

public class TableUnitTest extends TestCase {
	final static String driver = "com.mysql.jdbc.Driver";
	Connection con = null;
	Statement stmt = null;
	ISqlTable sqlTable = null;
	List<ColumnValue> myMap = null;
	
	protected void setUp() throws Exception {
		String url = "jdbc:mysql://localhost:3306/";
		// Load the Driver class. 
		Class.forName(driver);
		con = DriverManager.getConnection (url+ "CodeSharingDB", "root", "skravi");
		con.setAutoCommit(false);
		con.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE);
		stmt = con.createStatement();
		myMap = new ArrayList<ColumnValue>();
		myMap.add(new ColumnValue("try1", "int"));
		
	}

//	@Test
//	public void testCreateTable() throws SQLException{
//		sqlTable = new SqlTable(stmt, "users", myMap, "innodb");
//		sqlTable.createTable();
//		List<String> list = new LinkedList<String>();
//		list.add("5");
//		sqlTable.insertRecord(list);
//	}
	
//		@Test
//	public void testList()
//	{
//		List<String> list = new LinkedList<String>();
//		list.add("elad");
//		list.add("yoni");
//		
//		Assert.assertTrue(true);
//	}
//	
	@Test
	public void testIsolationLevel() throws SQLException{
		stmt.execute("insert into users values(1);");
		con.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
		//stmt.execute("select * from users;");
		con.commit();
	}
}
